package com.mycat.dfs;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author roger.
 * @email luojie@yzworld.cn
 * @date 2016/9/12
 */
public class Main {

    public static void main(String args[]) throws ParseException {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date DATE2 = df.parse("2016-09-21 00:00:00");
        int i = compare_date(DATE2);
        System.out.println("i==" + i);
    }

    /**
     * 验证输入时间是否大于当前时间
     * @param date 输入时间
     * @return 等于-1表示当前时间在输入时间之后
     */
    public static int compare_date(Date date) {
        Date currentDate = new Date();
        try {
            if (currentDate.getTime() > date.getTime()) {
                return 1;
            } else if (currentDate.getTime() < date.getTime()) {
                return -1;
            } else {
                return 0;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return 0;
    }
}
